library(readr)
library(dplyr)
# Set seed
set.seed(1996)
# Set Working Directory
#############################
rm(list=setdiff(ls(), c('script', 'scripts', 'log_file')))
#############################
# Load Master Data
master <- readRDS('master_withCFNom.rds')
# Create Candidate ID for Merging with Web Scores
master$candidate_id <- paste(master$candidate, master$state_postal, master$cd, master$year)

# Load WEB Scores
web_scores <- read.csv('webscore_estimates.csv')

# Fix Amy Wagner's name in Master
master$candidate_id[master$candidate_id == 'Ann Wagner MO 2 2022'] <- 'Amy Wagner MO 2 2022'

# Merge Web Scores with Master
master <- merge(master, web_scores, all.x = TRUE, by = c('candidate_id'))

# Save Data
saveRDS(master, 'master_web.rds')


